const jwt = require('jsonwebtoken');
const {PRIVATE_KEY} = require('../app/config')
class AuthController {
   login(ctx, next) {
    console.log(ctx.user,'user');
    const { id, name,avatar_url: url,pvmessage ,phone,industry} = ctx.user;
    const token = jwt.sign({ id, name }, PRIVATE_KEY, {
      expiresIn: 60 * 60 * 24,
      algorithm: 'RS256'
    });
    console.log( id, name, token );
    ctx.body = { id, name, token ,url ,pvmessage,phone,industry }
    // ctx.body = "你好小张"
  }
  async create(ctx, next) {
    ctx.body = "用户创建成功"
  }
  async pvmsg(ctx,next){
    if(ctx.pvmsg.length !=0) {
      ctx.body=ctx.pvmsg[0].pvmsginfo
    }else {
      ctx.body = ctx.pvmsg
    }
  }
  async pvwsmsg(ctx,next){
    ctx.body = ctx.pvwsmsg[0][0].pvmsginfo
  }
  
}

module.exports = new AuthController();